
import { reactive,onUnmounted } from 'vue';

// 坐标
const coord = reactive({
  startX: -1,
  startY: -1,
  endX: -1,
  endY: -1,
  maxHeight: 300,
  minHeight: 200,
})


 

export function useMouseMove (ref, moveEvent, downEvent) {
  ref.value.addEventListener("mousedown", commentDown)
  onUnmounted(() => {
    ref.value?.removeEventListener("mousedown", commentDown)
  })
// 鼠标弹起
  function commentUp (e) {
    window.removeEventListener("mousemove", commentMove)
  }

// 开始按下
  function commentDown (e) {
    // const { screenY } = e
    // coord.startY = screenY;
    downEvent??downEvent(e,coord)
    // 记录起始坐标
    window.addEventListener("mousemove", commentMove)
    window.addEventListener("mouseup", commentUp)
  }

  // 移动
  function commentMove (e) {
  
    moveEvent(e,coord)
  

}
  

}